package han.cirno.corrupt

import org.junit.Test
import java.util.Base64
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * @see [Testing documentation](http://d.android.com/tools/testing)
 */
class ExampleUnitTest{
    @Test
    fun aesEncryptTest(){
        val ori="0000000000000000000000000000000000000000000000000000000000000000114514"
        val key="iE1cQwdIz5GOPb5m"
        val iv= "0000000000000000"
        val cipher=Cipher.getInstance("AES/CBC/PKCS5Padding")
        val keySpec = SecretKeySpec(key.toByteArray(), "AES")
        val ivParameterSpec = IvParameterSpec(iv.toByteArray())
        cipher.init(Cipher.ENCRYPT_MODE,keySpec,ivParameterSpec)
        val final = cipher.doFinal(ori.toByteArray())
        println(Base64.getEncoder().encodeToString(final))
    }
}